﻿using FluentNHibernate.Mapping;

namespace NHibernate.Identity.Internal.Mapping
{
    public class IdentityUserMap<T> : ClassMap<T> where T : IdentityUser
    {
        public IdentityUserMap()
        {
            Id(x => x.Id);

            Map(x => x.UserName);
            Map(x => x.PasswordHash);
            Map(x => x.SecurityStamp);

            HasManyToMany(x => x.Roles)
                .Table("aspnet_UserRoles")
                .ParentKeyColumn("User_id")
                .ChildKeyColumn("Role_id")
                .Cascade.All();
            HasMany(x => x.Claims).KeyColumn("User_id").Cascade.All();
            HasMany(x => x.Logins).KeyColumn("User_id").Cascade.All();

            Table("aspnet_Users");
        }
    }

    public class DefaultIdentityUserMap : IdentityUserMap<IdentityUser>
    {
    }
}